---
import { site, author } from '@/config.json'

interface Props {
  title?: string
  description?: string
  image?: string
}

const { title = site.title, description = site.description, image } = Astro.props

const titleWithSiteSuffix = title === site.title ? title : `${title} - ${site.title}`
---

<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />

<link rel="apple-touch-icon" sizes="180x180" href={site.appleTouchIcon} />
<link rel="icon" href={site.favicon} />
<!-- L'Internationale, 
  Sera le genre humain. -->
<title>{titleWithSiteSuffix}</title>
<meta name="author" content={author.name} />
<meta name="description" content={description} />
<meta name="keywords" content={site.keywords} />
<meta name="generator" content={Astro.generator} />

<meta property="og:url" content={Astro.url} />
<meta property="og:type" content="website" />
<meta property="og:title" content={title} />
<meta property="og:description" content={description} />
{image && <meta property="og:image" content={new URL(image, Astro.url)} />}

<meta property="twitter:card" content="summary_large_image" />
<meta property="twitter:title" content={title} />
<meta property="twitter:description" content={description} />
{author.twitterId && <meta property="twitter:site" content={author.twitterId} />}
{image && <meta property="twitter:image" content={new URL(image, Astro.url)} />}

<link rel="canonical" href={new URL(Astro.url.pathname, Astro.site)} />
<link rel="sitemap" href="/sitemap-index.xml" />
<link
  rel="alternate"
  type="application/rss+xml"
  title={site.title}
  href={new URL('/rss.xml', Astro.url)}
/>
